import {useSelector, useDispatch} from 'react-redux'
import actionCreators from './aciton-creators'

function App() {
  const {count} = useSelector(state => state.tools)
  const dispatch = useDispatch()

  function btnClickHandle(type) {
    dispatch(actionCreators[type])
  }

  return <div>
    {count}
    <hr/>
    <button onClick={() => btnClickHandle('add')}>add</button>
    <button onClick={() => btnClickHandle('minus')}>minus</button>
    <button onClick={() => btnClickHandle('logger')}>logger</button>
    <button onClick={() => btnClickHandle('func')}>func</button>
    <button onClick={() => btnClickHandle('promises')}>promises</button>
    <button onClick={() => btnClickHandle('timeout')}>timeout</button>
  </div>
}

export default App
